}
impl Platform {
- fn combine(self, other: Platform) -> Platform {
+ pub fn combine(self, other: Platform) -> Platform {
match (self, other) {
(Platform::Target, Platform::Target) => Platform::Target,
(Platform::Plugin, Platform::Plugin) => Platform::Plugin,
// it once per context.
if !target.get_profile().is_custom_build() { continue }
let mut reqs = Vec::new();
- let requirement = targets.iter().find(|t| {
- !t.get_profile().is_custom_build() && !t.get_profile().is_doc()
- }).map(|&other_target| {
- cx.get_requirement(pkg, other_target)
+ let requirement = targets.iter().fold(None::<Platform>, |req, t| {
+ if !t.get_profile().is_custom_build() && !t.get_profile().is_doc() {
+ let r2 = cx.get_requirement(pkg, *t);
+ req.map(|r| r.combine(r2)).or(Some(r2))
+ } else {
+ req
+ }
}).unwrap_or(Platform::Target);
match requirement {
Platform::Target => reqs.push(Platform::Target),
Ok((Work::new(move |desc_tx| {
let mut rustc = rustc;
+ debug!("about to run: {}", rustc);
// Only at runtime have we discovered what the extra -L and -l
// arguments are for native libraries, so we process those here. We
pass_l_flag: bool,
current_id: &PackageId) -> CommandPrototype {
for id in native_lib_deps.into_iter() {
+ debug!("looking up {} {:?}", id, kind);
let output = &build_state[(id.clone(), kind)];
for path in output.library_paths.iter() {
rustc = rustc.arg("-L").arg(path);
assert_that(foo.cargo_process("build").env("SRC", Some(lib.as_vec())),
execs().with_status(0));
});
+
+test!(plugin_integration {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ build = "build.rs"
+
+ [lib]
+ name = "foo"
+ plugin = true
+ doctest = false
+ "#)
+ .file("build.rs", "fn main() {}")
+ .file("src/lib.rs", "")
+ .file("tests/it_works.rs", "");
+
+ assert_that(p.cargo_process("test"),
+ execs().with_status(0));
+});
assert_that(p.cargo_process("build").arg("--target").arg(&target).arg("-v"),
execs().with_status(0));
});
+
+test!(plugin_build_script_right_arch {
+ if disabled() { return }
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ build = "build.rs"
+
+ [lib]
+ name = "foo"
+ plugin = true
+ "#)
+ .file("build.rs", "fn main() {}")
+ .file("src/lib.rs", "");
+
+ assert_that(p.cargo_process("build").arg("-v").arg("--target").arg(alternate()),
+ execs().with_status(0)
+ .with_stdout(format!("\
+{compiling} foo v0.0.1 ([..])
+{running} `rustc build.rs [..]`
+{running} `[..]build-script-build[..]`
+{running} `rustc src[..]lib.rs [..]`
+", compiling = COMPILING, running = RUNNING)));
+});